/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import SessionFactory.SessionFactoryUtil;
import dto.Announcement;
import dto.AnnouncementHome;
import dto.JfMembers;
import dto.UserWarning;
import dto.UserWarningHome;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

/**
 *
 * @author Sci.Maha
 */
public class AnnAndWarn 
{
   AnnouncementHome home;
   UserWarningHome warnhome;
    public AnnAndWarn() {
        home=new AnnouncementHome();
        warnhome=new UserWarningHome();
    }
    
    
    
    public Vector<Announcement> getannouncement()
    {
        Vector<Announcement> ann=new Vector<Announcement>();
        Announcement anouncement=new Announcement();
        SessionFactoryUtil.startNew();
        List results = home.getannouncement();
        Iterator it = results.iterator();
           while (it.hasNext()) {
            Announcement us =  (Announcement) it.next();

            System.out.println(us.getAnnBody());
            System.out.print(us.getAnnDuration());
            System.out.print(us.getAnnId());
            ann.add(us);
            }
        SessionFactoryUtil.finish();  
        return ann;
    }
    
    public Vector<UserWarning> getwarn(JfMembers members)
    {
        Vector<UserWarning> warn=new Vector<UserWarning>();
        UserWarning warning=new UserWarning();
        SessionFactoryUtil.startNew();
          List results = warnhome.getwarn(members);
          Iterator it = results.iterator();
           while (it.hasNext()) {
            UserWarning us =   (UserWarning) it.next();
            System.out.println(us.getMessage());
            System.out.print(us.getWarningdate());         
            warn.add(us);
            }
        SessionFactoryUtil.finish();      
        return warn;
    }
    
    
    
    
    
}
